/*
---
name: MPG.Spinner

description:

license: MIT-style

authors:
- Noritaka Horio

requires:
  - Core/Core
  - Core/Function
  - Core/Element
  - Core/Element.Event
  - Core/Class
  - Core/Class.Extras

provides: [MPG.Spinner]

...
*/
(function($){

	var MPG = this.MPG = (this.MPG || {});

	MPG.Spinner = new Class({

		initialize: function(){
			this._setup();
		},

		_setup: function(){
			this._spinner = new Element('div', { 'class': 'spinner', 'styles': { 'opacity': 0 } });
			this._message = new Element('p', { 'class': 'message' });
			this._message.inject(this._spinner);
			this._spinner.inject(document.body);
		},

		setMessage: function(message){
			this._message.set('html', message);
		},

		getMessage: function(message){
			return this._message.set('html');
		},

		isShow: function(){
			return this._showed;
		},

		show: function(){
			var props = this._spinner.getSize();
			var y = -(props.y/2), x = -(props.x/2);
			this._spinner.setStyles({
				'margin-top': y,
				'margin-left': x
			});
			this._spinner.fade('in');
			this._showed = true;
		},

		hide: function(message){
			this._spinner.fade('out');
			this._showed = false;
		}

	});

}(document.id));
